package com.zdp.mybatisplus.common;


/**
 * @author sesshomaru
 * @date 2019/12/3 11:50
 * 数据源上下文
 */
public class DbContextHolder {
    private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();

    /**
     *设置数据源
     * @param dbTypeEnum
     */
    public static void setDbType(DBTypeEnum dbTypeEnum){
        contextHolder.set(dbTypeEnum.getValue());
    }

    /**
     * 获取当前数据源
     * @return
     */
    public static String getDbType(){
        return contextHolder.get();
    }

    /**
     *清除上下文
     */
    public static void clearDbType(){
        contextHolder.remove();
    }



}
